#ifndef pcb_H_GUARD
#define pcb_H_GUARD

/* all times assumed to be in milliseconds */


typedef struct  Process
{
   /* data */
   char* name; /* program's name */
   unsigned pid; /* unique id, simply incremented per program */
   unsigned start_time; /* start time of program */
   unsigned completed_io_ops; /* number of IOOperations, inc when each IO completed */
   unsigned timeline_size; /* number of IO Operations and size of io_timeline */
   unsigned cpu_time; /* total cputime the program will run for in */
   unsigned completed_cpu_time; /* completed cpu time */
   unsigned time_slice; /* time slice assigned by scheduler */
   unsigned completed_time_slice; /* amount of time slice completed < time_slice if preempted */
   unsigned priority;  /* used for 1st scheduler */

   /*void (*pfun1)(struct Process*, int);
   unsigned (*pfun2)(struct Process*);
   void (*pfun3)(struct Process*, int);
   unsigned (*pfun4)(struct Process*);*/
   
   unsigned* io_timeline; /*  times of IO ops from prog start time */

}PCB;

/* creates the PCB struct */
PCB* createPCB(char* CommandName,unsigned StartTime,double cputime,unsigned IOCount,unsigned pid);
/* creates an array of IO times relative to CPUTime */
unsigned* makeTimeline(unsigned IOOperations, unsigned CPUTime);
/* destroys the PCB struc */
void destroyPCB(PCB* pcb);

/* sets the completed cpu time */
void setCompletedTime(PCB* pcb, unsigned time);
/* returns the completed cpu time */
unsigned getCompletedTime(PCB* pcb);
/* returns the total cputime used by the process */
unsigned getCpuTime(PCB* pcb);
/* returns the assigned timeslice */
unsigned getTimeSlice(PCB* pcb);
/* sets the assigned timeslice */
void setTimeSlice(PCB* pcb, unsigned slice);
/* retunrs the number of ms completed for assigned slice */
unsigned getCompletedSlice(PCB* pcb);
/* sets the completed slice time */
void setCompletedSlice(PCB* pcb, unsigned slice);

/* sets the program's absolute start time */
void setStartTime(PCB* pcb, unsigned time);
/* returns the program's absolute start time */
unsigned getStartTime(PCB* pcb);

/* returns 1 if process has completed all cpu and io operations */
int isProcessComplete(PCB* pcb);

/* retunrs the name of the process */
char* getName(PCB* pcb);
/* sets the process's pid */
void setPid(PCB* pcb, unsigned pid);
/* returns the process's pid, assigned from 1 in order from trace file */
unsigned getPid(PCB* pcb);

/* returns the number of completed io operations */
unsigned getCompletedIO(PCB* pcb);
/* sets the number of completed io operations */
void setCompletedIO(PCB* pcb, unsigned value);
/* returns the cpu time that an io is to occur !!after!! */
unsigned getTimeLineValue(PCB* pcb, unsigned index);
/* number of io operations and size of timeline array */
unsigned getTimeLineSize(PCB* pcb);

/* returns the priority */
unsigned getPriority(PCB* pcb);
/* set the priority */
void setPriority(PCB* pcb,unsigned priority);



/*for test*/
void printTimeline(PCB *pcb);
void printStartPCB(PCB * pcb);
void printPCBState(const char* label, PCB* pcb);

#endif
